/*
 *
 * *******************************************************************
 *   @项目名称: BHex Android
 *   @文件名称: ViewHolder.java
 *   @Date: 11/29/18 3:21 PM
 *   @Author: chenjun
 *   @Copyright（C）: 2018 BlueHelix Inc.   All rights reserved.
 *   注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的.
 *  *******************************************************************
 *
 */

package io.bhex.baselib.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import io.bhex.baselib.R;

import io.bhex.baselib.utils.ViewFinder;


public class ViewHolder extends ViewFinder {

    @Deprecated
    private ViewFinder viewFinder;

    private View mItemView;

    private ViewHolder(View itemView) {
        super(itemView);
        mItemView = itemView;

        viewFinder = new ViewFinder(mItemView);

        mItemView.setTag(R.id.item_holder, this);
    }


    public View getItemView() {
        return mItemView;
    }

    @Deprecated
    public ViewFinder getViewFinder() {
        return viewFinder;
    }

    public static ViewHolder get(Context context, View itemView, ViewGroup parent, int layoutId) {
        if (itemView == null) {
            LayoutInflater inflater = LayoutInflater.from(context);
            itemView = inflater.inflate(layoutId, parent, false);

            return new ViewHolder(itemView);
        } else
            return (ViewHolder) itemView.getTag(R.id.item_holder);
    }

    public <V extends View> V get(int resId) {
        return super.find(resId);
    }
}
